<template>
  <div class="three">
    <dv-scroll-board
      :align="['center']"
      :config="config"
      style="width: 100%; height: 100%"
      class="table_arr"
      v-if="config.data.length > 0"
    />
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import { selectDeliveryDay } from "@/api/progress";

const config = ref({
  header: ["学校名称", "验收数量", "配送公司"],
  data: [],
});
const arr = [
  ["伊庄实小卫星厨房", "是"],
  ["棠张小学卫星厨房", "是"],
  ["大彭小学卫星厨房", "是"],
  ["科技谷卫星厨房", "是"],
  ["大学路北校区卫星厨房", "是"],
  ["汉王镇刘庄小学卫星厨房", "是"],
  ["利国镇磊庄卫星厨房", "是"],
  ["大许河西卫星厨房", "是"],
  ["茅村镇任庄卫星厨房", "是"],
  ["何桥镇金寨路卫星厨房", "是"],
  ["三堡实验小学卫星厨房", "是"],
  ["新区实验小学卫星厨房", "是"],
  ["马坡王堂幼儿园卫星厨房", "是"],
];

// 切换日期后，需要更新图表数据
const updateChartData = (data) => {
  let arr = []
  selectDeliveryDay({ week: data.week }).then((res) => {
    if (res.code == 200) {
      // const now = new Date();
      // const hours = now.getHours();
      res.data.forEach((item) => {
        arr.push([item.schoolName, `${item.count_all} / ${item.count_ok}`, item.deptName]);
      });

      config.value.data = arr;
    }
  });
};

defineExpose({
  updateChartData,
});

onMounted(() => {
  // 检查当前时间是否在上午10点前
});
</script>

<style lang='scss' scoped>
.table_arr {
  width: 100%;
  height: 100%;
}
.three {
  width: 95%;
  height: 90%;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  margin: auto;
}

.chart-wrapper {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
}

.chart-container {
  width: 100%;
  height: 100%;
}
</style>
